<template>
  <div class="body">
    <div class="title">便笺</div>
    <div class="search">
      <input @blur="isBlur = !isBlur" type="text" :placeholder="text" v-model="content">
      <div @click="content = ''" v-show="!!content"><i  class="el-icon-close"></i></div>
      <div><i class="el-icon-search"></i></div>
    </div>
  </div>
</template>

<script>

import { mapMutations } from 'vuex'

export default {
  name: 'Body',
  data () {
    return {
      text: '搜索...',
      content: '',
      isBlur: false // 判断输入框是否聚焦
    }
  },

  watch: {
    content () {
      this.searchTips(this.content)
    }
  },

  methods: {
    ...mapMutations(['searchTips'])
  }
}
</script>

<style lang="less" scoped>
.body {
  margin: 0 10px 0 10px;
}
.title {
  height: 30px;
  margin-bottom: 5px;
  line-height: 30px;
  text-align: left;
  font-weight: 700;
  color: #fff;
}

.search {
  width: 100%;
  height: 30px;
  background-color: rgb(64, 64, 64);
  display: flex;
  align-items: center;
  justify-content: center;

  input {
    display: block;
    // width: 100%;
    flex: 1;
    padding-left: 10px;
    border: none;
    // 去除 input 选中时的默认样式
    outline: none;
    color: rgb(113, 113, 113);
    background-color: rgb(64, 64, 64);
  }

  div {
    width: 30px;
    height: 30px;
    line-height: 30px;
    color: rgb(238, 238, 238);

    &:hover {
      background-color: rgb(77, 77, 77);
    }
  }
}
</style>
